package clientDemo.service.impl;

import clientDemo.entity.Mission;
import clientDemo.httpUtil.HttpRequest;
import clientDemo.httpUtil.HttpResponse;
import clientDemo.service.MissionService;
import com.alibaba.fastjson.JSON;

public class MissionServiceImpl implements MissionService {

	@Override
	public Mission get(String id) {
		HttpRequest request = HttpRequest.get("http://127.0.0.1:8080/api/v2/missions/" + id);
		HttpResponse response = request.send();
		int status = response.statusCode();
		if (status == 200) {
			return JSON.parseObject(response.body(), Mission.class);
		}
		return null;
	}
}